package com.justgame.project.service.system.service.basic;

import com.justgame.project.service.system.entity.SysUserRoleMapping;
import com.justgame.project.service.system.query.SysUserRoleMappingQuery;
import com.justgame.project.service.system.wrapper.SysUserRoleMappingWrapper;
import com.justgame.project.base.servcice.IBasicService;
import java.lang.Long;
import org.springframework.util.Assert;
import org.springframework.lang.NonNull;

/**
 *
 * 角色和用户关系映射表服务自定义查询类
 *
 * @@tableName sys_user_role_mapping
 * @author Zwb
 */
@SuppressWarnings("all")
public interface BasicSysUserRoleMappingService extends IBasicService<SysUserRoleMappingQuery,SysUserRoleMapping,SysUserRoleMappingWrapper> {

   /**
    * 新增创建
    * @param userInfoId 用户信息
    * @param roleId 角色信息
    */
   default SysUserRoleMapping baseAdd(Long userInfoId, Long roleId){
      SysUserRoleMapping sysUserRoleMapping = new SysUserRoleMapping();
      sysUserRoleMapping.setUserInfoId(safeValue(userInfoId, null));
      sysUserRoleMapping.setRoleId(safeValue(roleId, null));
      save(sysUserRoleMapping);
      return sysUserRoleMapping;
   }

   /**
    * 更新
    * @param userInfoId 用户信息
    * @param roleId 角色信息
    */
   default boolean baseUpdate(@NonNull SysUserRoleMapping sysUserRoleMapping,Long userInfoId, Long roleId){
      Assert.notNull(userInfoId,"必须提供用户信息");
      Assert.notNull(roleId,"必须提供角色信息");
      Assert.notNull(sysUserRoleMapping.getId(),"必须提供主键ID");
      sysUserRoleMapping.setUserInfoId(safeValue(userInfoId, null));
      sysUserRoleMapping.setRoleId(safeValue(roleId, null));
      return updateById(sysUserRoleMapping);
   }

}